//
//  ClinicPaymentInfoConroller.m
//  XinTaiPub
//
//  Created by rzhyios on 2018/5/31.
//  Copyright © 2018年 rzhy. All rights reserved.
//

#import "ClinicPaymentInfoConroller.h"
#import "Config.h"
#import <UIScrollView+EmptyDataSet.h>
#import "Patient.h"
#import "ClinicPatmentCell.h"

@interface ClinicPaymentInfoConroller ()<UITableViewDelegate, UITableViewDataSource>
{
    Patient *_patient;
    NSArray *_dataArray;
}
@property (weak, nonatomic) IBOutlet UITableView *tableView;

@end

@implementation ClinicPaymentInfoConroller

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    self.title = @"缴款信息";
    _patient = [Patient sharedPatient];
   // self.tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
    [self.tableView registerNib:[UINib nibWithNibName:@"ClinicPatmentCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"ClinicPatmentCell"];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    [self getZyjkjl];
}

#pragma mark - 缴款信息
- (void)getZyjkjl {
    NSDictionary *cookie = @{CookieVaule : [UserDefaultsTool stringForKey:XHToken]};
    NSDictionary *param = @{@"id" : @(_patient.id)};
    [HTTPSTool POSTRequestWithPath:XHUserMzjkjl cookie:cookie params:param success:^(NSDictionary * _Nonnull JSON) {
        XHLog(@"缴款信息 -> JSON: %@", JSON);
        _dataArray = JSON[@"data"][@"list"];
        [self.tableView reloadData];
    }];
}

#pragma mark - tableView delegate/dataSource Method
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    if (section == 0) {
        return 1;
    }else{
         return _dataArray.count;
    }
   
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 2;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return 55.0f;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    ClinicPatmentCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ClinicPatmentCell"];
    if (indexPath.section == 0) {
        cell.titleLabel.textColor = [UIColor redColor];
        cell.amountLabel.textColor = [UIColor redColor];
        return cell;
    }else{
        NSDictionary *dict = _dataArray[indexPath.row];
        cell.titleLabel.text = dict[@"jkrq"];
        cell.amountLabel .text = dict[@"jkje"];
        cell.titleLabel.textColor = [UIColor blackColor];
        cell.amountLabel.textColor = [UIColor blackColor];
        return cell;
    }
    
}

- (BOOL)tableView:(UITableView *)tableView shouldHighlightRowAtIndexPath:(NSIndexPath *)indexPath {
    return NO;
}

#pragma mark - DZNEmptyDataSetSource Method
- (UIImage *)imageForEmptyDataSet:(UIScrollView *)scrollView {
    UIImage *image = [UIImage imageNamed:@"LoadFailure.png"];
    return image;
}

- (NSAttributedString *)descriptionForEmptyDataSet:(UIScrollView *)scrollView {
    NSString *string = XHEmptyDes;
    NSAttributedString *abs = [[NSAttributedString alloc] initWithString:string attributes:nil];
    return abs;
}

- (CGFloat)verticalOffsetForEmptyDataSet:(UIScrollView *)scrollView {
    return -64.0f;
}

#pragma mark - DZNEmptyDataSetDelegate Method
- (BOOL)emptyDataSetShouldDisplay:(UIScrollView *)scrollView {
    return YES;
}

- (BOOL)emptyDataSetShouldAllowTouch:(UIScrollView *)scrollView {
    return YES;
}

- (BOOL)emptyDataSetShouldAllowScroll:(UIScrollView *)scrollView {
    return YES;
}

- (void)emptyDataSet:(UIScrollView *)scrollView didTapView:(UIView *)view {
    [self getZyjkjl];
}



@end
